package com.ds.infrastructure.hyperspace.console.model.request.deploy.deploydata;

import com.ds.infrastructure.hyperspace.console.config.validation.EnumValue;
import com.ds.infrastructure.hyperspace.console.dto.deploydata.HostDTO;
import com.ds.infrastructure.hyperspace.console.entity.enums.TbDeployConfigEnum;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotBlank;

/**
 * @author: yaozhendong
 * @create: 2019-10-21 10:50
 **/
@Data
@NoArgsConstructor
public class HostForm {
    @ApiModelProperty(value = "HOST类型:1(VM);2(Docker)")
    @EnumValue(TbDeployConfigEnum.HOST_TYPE.class)
    private Integer hostType;
    @NotBlank
    private String hostName;

    public static HostDTO toDTO(HostForm item) {
        HostDTO hostDTO = new HostDTO();
        hostDTO.setHostType(item.getHostType());
        hostDTO.setHostName(item.getHostName());
        return hostDTO;

    }

    public static HostForm toVO(HostDTO dto) {
        HostForm hostForm = new HostForm();
        hostForm.setHostType(dto.getHostType());
        hostForm.setHostName(dto.getHostName());
        return hostForm;
    }
}
